package com.ithei.多线程第二天.线程池;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        ExecutorService pool = Executors.newCachedThreadPool();
        pool.submit(() -> {
            System.out.println(Thread.currentThread().getName() + "正在执行线程.................");
        }, "线程一");
        Thread.sleep(2000);
        pool.submit(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName() + "正在执行线程=================");
            }
        }, "线程二");
        pool.submit(() -> {
            System.out.println(Thread.currentThread().getName() + "正在执行线程.........................");
        }, "线程三");
        pool.submit(() -> {
            System.out.println(Thread.currentThread().getName() + "正在执行线程=======================");
        }, "线程四");
        pool.shutdown();


    }
}
